package com.kuang.service.order;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kuang.entity.Order;
import com.kuang.mapper.OrderMapper;
import org.springframework.stereotype.Service;

/**
 * @title: OrderServiceImpl
 * @Author xiaozhen
 * @Date: 2021/9/6 15:46
 * @Version 1.0
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService  {



     public int countUserMakeOrder(Long userId,Long productId){
         LambdaQueryWrapper<Order> lambdaQueryWrapper = new LambdaQueryWrapper<>();
         lambdaQueryWrapper.eq(Order::getUserId,userId);
         lambdaQueryWrapper.eq(Order::getProductId,productId);
         int count = this.count(lambdaQueryWrapper);
         return  count;
     }

//    public int countUserMakeOrders(Long userId, Long productId) {
//        LambdaQueryWrapper<Order> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//        lambdaQueryWrapper.eq(Order::getUserId, userId);
//        lambdaQueryWrapper.eq(Order::getProductId, productId);
//        int count = this.count(lambdaQueryWrapper);
//        return count;
//    }
     public void saveOrder(Order order){
         boolean saveOrUpdate = this.saveOrUpdate(order);
     }
}
